package com.my.kq.controller;

import com.my.kq.service.LeaveService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

@WebServlet("/AgreeServlet")
public class AgreeServlet extends HttpServlet {
    public LeaveService leaveService=new LeaveService();
    @Override
    protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            //将审批状态改为已批准
            req.setCharacterEncoding("utf-8");
            resp.setContentType("text/html;charset=utf-8");
            String id = req.getParameter("id");
            leaveService.setAgree(Integer.parseInt(id));
            req.getRequestDispatcher("notlist.do").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req,resp);
    }
}
